import { request } from "@/utils/http";

//引入类型限制
import type {
  getHosListSearchParamsType,
  hospitalListReqReturnType,
  ProvinceType,
  hospitalDetailReturnType,
  hosDepartmentListType,
  hosScheduleRuleParamsType,
  hosScheduleRuleReturnType,
  findScheduleListParamsType,
  findScheduleListType,
} from "./model/hospitalList";

//获取医院列表数据请求
export const getHosListRequest = (
  page: number,
  limit: number,
  searchParams: getHosListSearchParamsType
) => {
  return request.get<any, hospitalListReqReturnType>(
    `/admin/hosp/hospital/${page}/${limit}`,
    {
      params: searchParams,
    }
  );
};

//获取省份数据请求
export const getProvinceRequest = () => {
  return request.get<any, ProvinceType>(
    "/admin/cmn/dict/findByDictCode/province"
  );
};
//获取市区数据请求
export const getCityListRequest = (value: string) => {
  return request.get<any, ProvinceType>(
    `/admin/cmn/dict/findByParentId/${value}`
  );
};
//获取县数据请求
export const getCountyRequest = (value: string) => {
  return request.get<any, ProvinceType>(
    `/admin/cmn/dict/findByParentId/${value}`
  );
};

//获取医院展示请求
export const getHosListShowRequest = (id: string) => {
  return request.get<any, hospitalDetailReturnType>(
    `/admin/hosp/hospital/show/${id}`
  );
};

//更新医院上下线状态请求
export const getChangestatusRequest = (id: string, status: 0 | 1) => {
  return request.get<any, null>(
    `/admin/hosp/hospital/updateStatus/${id}/${status}`
  );
};

//医院科室列表请求
export const getHosDepartmentRequest = (hoscode: string) => {
  return request.get<any, hosDepartmentListType>(
    `/admin/hosp/department/${hoscode}`
  );
};

//某个科室详细排班时间请求
export const gethosScheduleRuleRequest = ({
  page,
  limit,
  hoscode,
  depcode,
}: hosScheduleRuleParamsType) => {
  return request.get<any, hosScheduleRuleReturnType>(
    `/admin/hosp/schedule/getScheduleRule/${page}/${limit}/${hoscode}/${depcode}`
  );
};

//获取workDate排班日期的排班详细列表
export const getFindScheduleListRequest = ({
  hoscode,
  depcode,
  workDate,
}: findScheduleListParamsType) => {
  return request.get<any, findScheduleListType>(
    `/admin/hosp/schedule/findScheduleList/${hoscode}/${depcode}/${workDate}`
  );
};
